from tkinter import *

# from MainPage.view import InputFrame, QueryFrame, AlterFrame
from worker.view import InputFrame, QueryFrame, AlterFrame


class MainPage(object):
    def __init__(self, master=None):
        self.root = master  # 定义内部变量root
        self.root.geometry('%dx%d' % (650, 400))
        self.createPage()

    def createPage(self):
        self.inputPage = InputFrame(self.root)  # 录入
        self.queryPage = QueryFrame(self.root)  # 插入地点
        self.alterPage = AlterFrame(self.root)  # 修改
        self.inputPage.pack()  # 默认显示数据录入界面
        menubar = Menu(self.root)
        menubar.add_command(label='数据录入', command=self.inputData)
        menubar.add_command(label='地点插入', command=self.queryData)
        menubar.add_command(label='修改', command=self.alterData)
        self.root['menu'] = menubar  # 设置菜单栏

    def inputData(self):
        self.inputPage.pack()
        self.queryPage.pack_forget()
        self.alterPage.pack_forget()

    def queryData(self):
        self.inputPage.pack_forget()
        self.queryPage.pack()
        self.alterPage.pack_forget()

    def alterData(self):
        self.inputPage.pack_forget()
        self.queryPage.pack_forget()
        self.alterPage.pack()
